<template>
  <view class="system-info-container">
    <!-- 自定义导航栏 -->
    <view class="custom-nav" :style="navStyle">
      <view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
      <view class="nav-bar" :style="{ height: navBarHeight + 'px' }">
        <view class="nav-title">系统信息</view>
      </view>
    </view>

    <!-- 内容区域 -->
    <view class="content" :style="{ paddingTop: totalTopHeight + 'px' }">
      <view class="info-card">
        <view class="info-title">系统信息详情</view>
        <view class="info-item">
          <text class="label">状态栏高度:</text>
          <text class="value">{{ statusBarHeight }}px</text>
        </view>
        <view class="info-item">
          <text class="label">导航栏高度:</text>
          <text class="value">{{ navBarHeight }}px</text>
        </view>
        <view class="info-item">
          <text class="label">顶部总高度:</text>
          <text class="value">{{ totalTopHeight }}px</text>
        </view>
        <view class="info-item">
          <text class="label">平台:</text>
          <text class="value">{{ systemInfo.platform }}</text>
        </view>
        <view class="info-item">
          <text class="label">设备型号:</text>
          <text class="value">{{ systemInfo.model }}</text>
        </view>
        <view class="info-item">
          <text class="label">窗口宽度:</text>
          <text class="value">{{ systemInfo.windowWidth }}px</text>
        </view>
        <view class="info-item">
          <text class="label">窗口高度:</text>
          <text class="value">{{ systemInfo.windowHeight }}px</text>
        </view>
      </view>

      <view class="info-card">
        <view class="info-title">胶囊按钮信息</view>
        <view class="info-item">
          <text class="label">宽度:</text>
          <text class="value">{{ menuButtonInfo.width }}px</text>
        </view>
        <view class="info-item">
          <text class="label">高度:</text>
          <text class="value">{{ menuButtonInfo.height }}px</text>
        </view>
        <view class="info-item">
          <text class="label">top:</text>
          <text class="value">{{ menuButtonInfo.top }}px</text>
        </view>
        <view class="info-item">
          <text class="label">right:</text>
          <text class="value">{{ menuButtonInfo.right }}px</text>
        </view>
      </view>

      <view class="demo-section">
        <view class="demo-title">使用示例</view>
        <view class="demo-text">
          所有页面都可以通过导入 systemUtils 来获取系统信息：
        </view>
        <view class="code-block">
          import { systemUtils } from '@/utils/system.js'
          
          const totalTopHeight = systemUtils.getTotalTopHeight()
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { computed } from 'vue'
import { systemUtils } from '@/utils/system.js'

// 系统信息
const statusBarHeight = computed(() => systemUtils.getStatusBarHeight())
const navBarHeight = computed(() => systemUtils.getNavBarHeight())
const totalTopHeight = computed(() => systemUtils.getTotalTopHeight())
const navStyle = computed(() => systemUtils.getCustomNavStyle())
const systemInfo = computed(() => systemUtils.getSystemInfo())
const menuButtonInfo = computed(() => systemUtils.getMenuButtonInfo())
</script>

<style scoped>
.system-info-container {
  min-height: 100vh;
  background: #f5f5f5;
}

.custom-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #ffffff;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}

.status-bar {
  width: 100%;
  background: #ffffff;
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.nav-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #333333;
}

.content {
  padding: 20rpx;
}

.info-card {
  background: #ffffff;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}

.info-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #333333;
  margin-bottom: 20rpx;
  border-bottom: 1rpx solid #f0f0f0;
  padding-bottom: 20rpx;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16rpx 0;
  border-bottom: 1rpx solid #f8f8f8;
}

.info-item:last-child {
  border-bottom: none;
}

.label {
  font-size: 28rpx;
  color: #666666;
}

.value {
  font-size: 28rpx;
  color: #333333;
  font-weight: 500;
}

.demo-section {
  background: #ffffff;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-top: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}

.demo-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #333333;
  margin-bottom: 20rpx;
}

.demo-text {
  font-size: 28rpx;
  color: #666666;
  margin-bottom: 20rpx;
  line-height: 1.6;
}

.code-block {
  background: #f8f8f8;
  border-radius: 8rpx;
  padding: 20rpx;
  font-size: 24rpx;
  color: #333333;
  font-family: monospace;
  white-space: pre-line;
  line-height: 1.4;
}
</style>